Include: helper.2apl
 
 
PC-rules:


	/* 
	 * Method: registerAndMatchRequest
	 * From: Buyer
	 * Param: Item
	 * Return: list of sellers to Buyer
	 */
	message( Buyer, request, _, _, registerAndMatchRequest(Item) ) <- true | 
	{
		@emarket( registerRequest(Item, Buyer), _);
		@emarket( findMatchingOffers(Item, Buyer), ListOfSellers);
		B( ListOfSellers = [actionresult( Sellers )] );
		send( Buyer, inform, sellersForItem( Item, Sellers ) )
	}
	
	/* 
	 * Method: removeRequest
	 * From: Buyer
	 * Param: Item
	 * Return: void
	 */
	message( Buyer, inform, _, _, removeRequest( Item ) ) <- true |
	{
		@emarket( removeRequest( Item, Buyer ), _ )
	}
	

	
	/* 
	 * Method: registerOffer
	 * From: Seller
	 * Param: Item
	 * Return: New Seller to all Buyers of that Item
	 */
	message( Seller, inform, _, _, registerOffer( Item ) ) <- true |
	{
		@emarket( registerOffer( Item, Seller ), ListOfBuyers );
		B( ListOfBuyers = [actionresult( Buyers )] );
		sendAll( Buyers, inform, sellersForItem( Item, [Seller] ) )
	}
	
	
	/* 
	 * Method: removeOffer
	 * From: Seller
	 * Param: Item
	 * Return: Removed Seller to all Buyers of that Item
	 */
	message( Seller, inform, _, _, removeOffer( Item ) ) <- true |
	{
		@emarket( removeOffer( Item, Seller ), ListOfBuyers );
		B( ListOfBuyers = [actionresult( Buyers )] );
		sendAll( Buyers, inform, removedOffer( Item, Seller ) )
	}
		
	
